﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineCooperation.DB;
using OnlineCooperation.Entity;

namespace OnlineCooperation
{
    public partial class TeamIndex : System.Web.UI.Page
    {
        protected List<Team> tlist;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null || Session["UserID"].ToString() == "")
            {
                Response.Write("<script>alert('用户尚未登录！');window.location='Login.aspx';</script>");
            }
            RelUserTeamDB reld=new  RelUserTeamDB();
            UserDB ud=new UserDB();
            User u=ud.GetUserByID(int.Parse(Session["UserID"].ToString()));
            tlist = reld.GetAllTeam(u);

            if (IsPostBack)
            {
                string a1=Request.Form["__EVENTTARGET"];
                if (a1 == "viewteam_click")
                {
                    string a2 = Request.Form["__EVENTARGUMENT"];
                    Session["TeamID"] = tlist[int.Parse(a2)].ID;
                    Response.Redirect("TeamPage.aspx");
                }
                else if (a1 == "createteam_click")
                {
                    Response.Redirect("SetupTeam.aspx");
                }
            }
        }
    }
}